/*    */ package com.cr.web.controller.monitor;
/*    */ 
/*    */ import com.cr.common.annotation.Log;
/*    */ import com.cr.common.core.controller.BaseController;
/*    */ import com.cr.common.core.domain.AjaxResult;
/*    */ import com.cr.common.core.page.TableDataInfo;
/*    */ import com.cr.common.core.text.Convert;
/*    */ import com.cr.common.enums.BusinessType;
/*    */ import com.cr.common.enums.OnlineStatus;
/*    */ import com.cr.common.utils.ShiroUtils;
/*    */ import com.cr.framework.shiro.session.OnlineSession;
/*    */ import com.cr.framework.shiro.session.OnlineSessionDAO;
/*    */ import com.cr.system.domain.SysUserOnline;
/*    */ import com.cr.system.service.ISysUserOnlineService;
/*    */ import java.util.List;
/*    */ import org.apache.shiro.authz.annotation.Logical;
/*    */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*    */ import org.apache.shiro.session.Session;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.web.bind.annotation.GetMapping;
/*    */ import org.springframework.web.bind.annotation.PostMapping;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/monitor/online"})
/*    */ public class SysUserOnlineController extends BaseController {
/* 34 */   private String prefix = "monitor/online";
/*    */   
/*    */   @Autowired
/*    */   private ISysUserOnlineService userOnlineService;
/*    */   
/*    */   @Autowired
/*    */   private OnlineSessionDAO onlineSessionDAO;
/*    */   
/*    */   @RequiresPermissions({"monitor:online:view"})
/*    */   @GetMapping
/*    */   public String online() {
/* 46 */     return this.prefix + "/online";
/*    */   }
/*    */   
/*    */   @RequiresPermissions({"monitor:online:list"})
/*    */   @PostMapping({"/list"})
/*    */   @ResponseBody
/*    */   public TableDataInfo list(SysUserOnline userOnline) {
/* 54 */     startPage();
/* 55 */     List<SysUserOnline> list = this.userOnlineService.selectUserOnlineList(userOnline);
/* 56 */     return getDataTable(list);
/*    */   }
/*    */   
/*    */   @RequiresPermissions(value = {"monitor:online:batchForceLogout", "monitor:online:forceLogout"}, logical = Logical.OR)
/*    */   @Log(title = "在线用户", businessType = BusinessType.FORCE)
/*    */   @PostMapping({"/batchForceLogout"})
/*    */   @ResponseBody
/*    */   public AjaxResult batchForceLogout(String ids) {
/* 65 */     for (String sessionId : Convert.toStrArray(ids)) {
/* 67 */       SysUserOnline online = this.userOnlineService.selectOnlineById(sessionId);
/* 68 */       if (online == null)
/* 70 */         return error("用户已下线"); 
/* 72 */       OnlineSession onlineSession = (OnlineSession)this.onlineSessionDAO.readSession(online.getSessionId());
/* 73 */       if (onlineSession == null)
/* 75 */         return error("用户已下线"); 
/* 77 */       if (sessionId.equals(ShiroUtils.getSessionId()))
/* 79 */         return error("当前登录用户无法强退"); 
/* 81 */       this.onlineSessionDAO.delete((Session)onlineSession);
/* 82 */       online.setStatus(OnlineStatus.off_line);
/* 83 */       this.userOnlineService.saveOnline(online);
/* 84 */       this.userOnlineService.removeUserCache(online.getLoginName(), sessionId);
/*    */     } 
/* 86 */     return success();
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\web\controller\monitor\SysUserOnlineController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */